package com.easy.order.controller;

import com.easy.common.bean.Goods;
import com.easy.common.service.IGoodsService;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    @DubboReference
    IGoodsService goodsService;

    @RequestMapping("/getOrder")
    public String getOrder() {
     Goods goods = goodsService.getGoodsById(1);
        System.out.println( goods);
        return "getOrder";

    }

    @GlobalTransactional
    @RequestMapping("/addOrder")
    public String addOrder(){
        Goods goods = goodsService.getGoodsById(1);
        goods.setId( null);
        goodsService.addGoods(goods);

        return "addOrder";
    }
}
